<?php

namespace Kicker\MainBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Kicker\MainBundle\Controller\GameController;

class SendCommand extends ContainerAwareCommand {

    protected function configure() {
        
        $this
            ->setName('Kicker:send')
            ->setDescription('Greet someone')
            ->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
            ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
        ;
    }
  

//    protected function execute(InputInterface $input, OutputInterface $output) {
//        
//        $email = $input->getArgument('name');
//
//        $message = \Swift_Message::newInstance()
//            ->setSubject('God want you to save.....')
//            ->setFrom('god@trivago.com')
//            ->setTo($email)
//            ->setBody("Welcome my local mail server!!!")
//        ;
//        $mailer = $this->getContainer()->get('mailer');
//        $mailer->send($message);
//        
//        $output->writeln("Sent");
//    }
    
//    protected function execute(InputInterface $input, OutputInterface $output) {
//        
//        $gameController = new GameController();
//        $em = $this->getContainer()->get('doctrine')->getManager();
//        $msgs = $gameController->getPendingGames($em);
//        $mailer = $this->getContainer()->get('mailer');
//        foreach($msgs as $msg){
//            var_dump($msg['dest']);
//            die();
//            foreach($msg['dest'] as $to){
//                $message = \Swift_Message::newInstance()
//                    ->setSubject('Match pending...')
//                    ->setFrom('kicker@trivago.com')
//                    ->setTo($to)
//                    ->setBody("You have a match pending in Kicker Trivago. Please, go to this URL dev.trivago.kicker");
//                ;
//                $mailer->send($message);
//            }
////            $body = $this->renderView('KickerMainBundle:Game:pending.html.twig', array('game' => $msg->game));
//        }
//        
//        $output->writeln("Mails sent correctly");
//    }
//    
    protected function execute(InputInterface $input, OutputInterface $output) {
        $value = $input->getArgument('name');
        $client= new \GearmanClient();
        $client->addServer();
        print $client->doNormal("mails", "\n Hello World!");
    }

}